/**
 * Author: Brent Myers
 * Time-stamp: <2008-07-23 17:15:28 bam>
 * 
 * string hash tests
 * 
 */

#include <boost/test/unit_test.hpp>

#include "src/Chaining.h"
#include "src/SimpleHash.h"
#include "src/Hashtable.h"
#include "src/ModuloHash.h"
#include "src/BitmaskHash.h"

#include <utility>
#include <string>


using std::string;
using std::make_pair;

using namespace genhash;

struct HTTestConfig1 
{
	enum { max_size = 10 };
	typedef string KeyType;
	typedef string DataType;
	typedef SimpleModuloHash<HTTestConfig1> HashFn;
	typedef Chaining<HTTestConfig1> CollisionStrategy;
	typedef Hashtable<CollisionStrategy> RET;
};
typedef HTTestConfig1::RET HT1;


BOOST_AUTO_TEST_CASE( strs1 )
{
	HT1 ht;
	string key("abc");
	string val("def");
	ht.insert(make_pair(key, val));
	HT1::iterator it(ht.find(key));
	BOOST_CHECK_EQUAL(it->first, key);
	BOOST_CHECK_EQUAL(it->second, val);
}


BOOST_AUTO_TEST_CASE( strs2 )
{
	HT1 ht;
	string key1("abc");
	string val1("def");
	string key2("abcd");
	string val2("defg");
	ht.insert(make_pair(key1, val1));
	ht.insert(make_pair(key2, val2));
	HT1::iterator it1(ht.find(key1));
	BOOST_CHECK_EQUAL(it1->first, key1);
	BOOST_CHECK_EQUAL(it1->second, val1);
	HT1::iterator it2(ht.find(key2));
	BOOST_CHECK_EQUAL(it2->first, key2);
	BOOST_CHECK_EQUAL(it2->second, val2);
}

